package fr.pascal.client.ui.barre;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class BarreNavigationImpl extends Composite implements BarreNavigation {

	private static BarreNavigationImplUiBinder uiBinder = GWT.create(BarreNavigationImplUiBinder.class);
	private Presenter presenter;
	
	@UiField
	Anchor accueil;
	
	@UiField
	Label rubrique;

	interface BarreNavigationImplUiBinder extends
			UiBinder<Widget, BarreNavigationImpl> {
	}

	public BarreNavigationImpl() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}

	@Override
	public void setSelectedRubrique(String selectedRubrique) {
		if ("1".equals(selectedRubrique)) {
			rubrique.setText("WWE");
		} else if ("2".equals(selectedRubrique)) {
			rubrique.setText("Animaux");
		} 
	}
	
	@UiHandler("accueil")
	void onAccueilClick(ClickEvent event) {
		presenter.goToAccueil();
	}
}
